// pages/course/onlineCourse/onlineCourse.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    option1: [
      { text: '综合排序', value: 0 },
    ],
    option2: [
      { text: '人气', value: 0 },
    ],
    option3: [
      { text: '好评率', value: 0 },
    ],
    option4: [
      { text: '价格', value: 'a' },
      { text: '价格升序', value: 'b' },
      { text: '价格降序', value: 'c' },
    ],
    option5: [
      { text: '价格区间', value: 0 },
      { text: '0-50', value: 1 },
      { text: '50-100', value: 2 },
      { text: '100-150', value: 3 },
      { text: '150-200', value: 4 },
      { text: '200-250', value: 5 },
      { text: '250-300', value: 6 },
    ],
    value:"",
    value1: 0,
    value2: 'a',
    value3:1,
    value4:2,
    value5:3,
    a:100,
    b:100,
    totalCourseList:"",
    startPrice:"",
    endPrice:"",
  },
  clickPrice:function(res){
    console.log(res)
    let that = this;
    that.setData({
      value:res.detail
    })
    console.log(that.data.value)
    if(that.data.value==1){
      that.setData({
        startPrice:0,
        endPrice:50
      })
    }else if(that.data.value==2){
      that.setData({
        startPrice:50,
        endPrice:100
      })
    }else if(that.data.value==3){
      that.setData({
        startPrice:100,
        endPrice:150
      })
    }else if(that.data.value==4){
      that.setData({
        startPrice:150,
        endPrice:200
      })
    }else if(that.data.value==5){
      that.setData({
        startPrice:200,
        endPrice:250
      })
    }else if(that.data.value==6){
      that.setData({
        startPrice:250,
        endPrice:300
      })
    }else{
      that.setData({
        startPrice:0,
        endPrice:100000
      })
    }
    wx.request({
      url: 'http://localhost:8080/course/coursePriceList',
      data:{
        startPrice:that.data.startPrice,
        endPrice:that.data.endPrice
      },
      success(resp){
        console.log(that.data.startPrice)
        console.log(that.data.endPrice)
        console.log(resp.data.data)
        that.setData({
          totalCourseList:resp.data.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this;
    //请求后端数据
    wx.request({
      url: 'http://localhost:8080/course/courseList',
      success(resp){
        that.setData({
          totalCourseList:resp.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})